﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace FieldTools.Util.Helper
{
    //可能会用到的kernel32函数，按需添加使用，集中管理
    public class Kernel32Helper
    {
        /// <summary>
        /// 打开控制台（当前进程）
        /// </summary>
        [DllImport("kernel32.dll", EntryPoint = "AllocConsole", CharSet = CharSet.Auto)]
        public static extern bool AllocConsole();
        /// <summary>
        /// 释放控制台（当前进程）
        /// </summary>
        [DllImport("kernel32.dll", EntryPoint = "FreeConsole", CharSet = CharSet.Auto)]
        public static extern bool FreeConsole();
        /// <summary>
        /// 获取控制台窗口句柄（当前进程）
        /// </summary>
        [DllImport("kernel32.dll", EntryPoint = "GetConsoleWindow", CharSet = CharSet.Auto)]
        public static extern IntPtr GetConsoleWindow();

        /// <summary>
        /// 刷新控制台输出
        /// </summary>
        [DllImport("kernel32.dll", EntryPoint = "FlushConsoleInputBuffer", CharSet = CharSet.Auto)]
        public static extern Boolean FlushConsoleInputBuffer();
    }
}
